<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>03_JS数据类型</title>
</head>
<body>
<script>
    //JS数据类型 = 原始类型 + 引用类型
    // 原始类型：number string boolean undefined null
    //引用类型：object array function..
    var a = 1;
    var b = 3.21;
    console.log(a,typeof a,b ,typeof b );
    var c = "hello";
    var d = '你好';
    console.log(c,typeof c,d ,typeof d );
    var e = true;
    var f = false;
    console.log(e,typeof e,f ,typeof f );
    var g;
    console.log(g,typeof g);
    //引用类型
    let obj = {
        name:"张三",
        age:18,
        sex:"男"
    };
    console.log(obj,typeof obj);
    console.log(obj.name,obj.age,obj.sex);

    obj.like = "打游戏";//可以中途定义类型
    console.log(obj);

    /////////////JS数组
    let arr = ['张三',18,'男'];
    console.log(arr,typeof arr);
    console.log(arr[0],arr[1],arr[2]);

    ////Boolean（）用于将参数转化为布尔类型
    console.log(Boolean(0));
    console.log(Boolean(undefined));
    console.log(Boolean(null));
    console.log(Boolean(""));
    console.log(Boolean(NaN));//not a number
    console.log('------------------')
    console.log(Boolean(1));
    console.log(Boolean(' '));
    console.log(Boolean('hello'));

    ////Number（）用于将参数转化为数值类型
    console.log(Number(true),typeof Number(true));
    console.log(Number(false),typeof Number(false));
    console.log(Number(1),typeof Number(1));
    console.log(Number('123'),typeof Number('123'));
    console.log(Number('hello'),typeof Number('hello'));

</script>
</body>
</html>